#include "gateway_server.hpp"


DEFINE_bool(debug, true, "默认开启debug模式");
DEFINE_string(logPath, "", "发布模式下，日志路径");
DEFINE_int32(logLevel, 0, "发布模式下，日志级别");

DEFINE_string(registryHost, "http://127.0.0.1:2379", "etcd的IP地址");

DEFINE_string(baseService, "/service", "服务监控根目录");
DEFINE_string(fileService, "/service/file_service", "文件管理子服务名称");
DEFINE_string(friendService, "/service/friend_service", "好友管理子服务名称");
DEFINE_string(messageService, "/service/message_service", "消息存储子服务名称");
DEFINE_string(transmiteService, "/service/transmite_service", "消息转发子服务名称");
DEFINE_string(userService, "/service/user_service", "用户管理子服务名称");
DEFINE_string(speechService, "/service/speech_service", "语音识别子服务名称");

DEFINE_int32(http_listenPort, 9000, "http服务器监听端口");
DEFINE_int32(ws_listenPort, 9001, "websocket服务器监听端口");

DEFINE_string(redis_host, "127.0.0.1", "Redis服务器访问地址");
DEFINE_int32(redis_port, 6379, "Redis服务器访问端口");
DEFINE_int32(redis_db, 0, "Redis默认库号");
DEFINE_bool(redis_keep_alive, true, "Redis长连接保活选项");


int main(int argc, char *argv[]){
    google::ParseCommandLineFlags(&argc, &argv, true);
    im::initLogger(FLAGS_debug, FLAGS_logPath, FLAGS_logLevel);

    im::GatewayServiceBuild gsb;
    std::vector<std::string> service_paths = {
        FLAGS_fileService,
        FLAGS_friendService,
        FLAGS_messageService,
        FLAGS_transmiteService,
        FLAGS_userService,
        FLAGS_speechService
    };
    gsb.init_discovery_client(FLAGS_registryHost, FLAGS_baseService, service_paths);
    gsb.init_Redis_client(FLAGS_redis_host, FLAGS_redis_port, FLAGS_redis_db, FLAGS_redis_keep_alive);
    gsb.init_server_port(FLAGS_ws_listenPort, FLAGS_http_listenPort);
    auto server = gsb.build();
    server->start();
    return 0;
}